// pages/login/login.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    detail:[
      { id: '1' }, { id: '2' }, { id: '3' }, { id: '4' }, { id: '5' }, { id: '6' },
      { id: '7' }, { id: '8' }, { id: '9' }, { id: '10' }, { id: '11' }, { id: '12' },
      { id: '13' }, { id: '14' }, { id: '15' }, { id: '16' }, { id: '17' }, { id: '18' },
      { id: '19' }, { id: '20' }
    ],
    aaa:[],
    bbb:[],
    page: '1',//分页
    limit: '20',//每页数量
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this
    let detail = that.data.detail
    let value = ''
    for(let i = 0;i < detail.length;i++){
      value = (i+1)/2
      if (/^\d{1,10}(\.\d{0,0})?$/.test(value)) {
        that.data.bbb.push(detail[i])
      } else {
        that.data.aaa.push(detail[i])
      }
    }
    console.log('aaa',that.data.aaa)
    console.log('bbb', that.data.bbb)
    that.setData({
      aaa:that.data.aaa,
      bbb:that.data.bbb,
    })
  },

  /**
   * 跳转生活界面
   */
  toLife(){
    wx.navigateTo({
      url:'/goodPackage/pages/life/life'
    })
  },
  /**
   * 跳转书籍界面
   */
  toBook(){
    wx.navigateTo({
      url:'/goodPackage/pages/book/book'
    })
  },
  /**
   * 跳转电子产品界面
   */
  toElectronic(){
    wx.navigateTo({
      url:'/goodPackage/pages/electronic/electronic'
    })
  },
  /**
   * 跳转其他界面
   */
  toOther(){
    wx.navigateTo({
      url:'/otherPackage/pages/other/other'
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function (e) {
    let that = this
    let detail = that.data.detail
    let value = ''
    if (that.data.page * that.data.limit == (that.data.aaa.length + that.data.bbb.length)) {
      that.data.page++
      for (let i = 0; i < detail.length; i++) {
        value = (i + 1) / 2
        if (/^\d{1,10}(\.\d{0,0})?$/.test(value)) {
          that.data.bbb.push(detail[i])
        } else {
          that.data.aaa.push(detail[i])
        }
      }
      console.log('aaa', that.data.aaa)
      console.log('bbb', that.data.bbb)
      that.setData({
        aaa: that.data.aaa,
        bbb: that.data.bbb,
      })
    }
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})